home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / catman / p_man / cat3 / qintcache.Z / qintcache
Encoding:
Text File  |  1998-10-28  |  14.8 KB  |  265 lines

  1.  
  2.  
  3.  
  4.      QQQQIIIInnnnttttCCCCaaaacccchhhheeee((((3333qqqqtttt))))    TTTTrrrroooollllllll TTTTeeeecccchhhh AAAASSSS ((((9999 JJJJuuuullllyyyy 1111999999998888))))    QQQQIIIInnnnttttCCCCaaaacccchhhheeee((((3333qqqqtttt))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       QIntCache - Template class that provides a cache based on
  10.       long keys
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.       #include <qintcache.h>
  14.  
  15.       Inherits QGCache.
  16.  
  17.     PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrrssss
  18.       QQQQIIIInnnnttttCCCCaaaacccchhhheeee (((( ccccoooonnnnsssstttt QQQQIIIInnnnttttCCCCaaaacccchhhheeee<<<<ttttyyyyppppeeee>>>> &&&& cccc    ))))
  19.       QQQQIIIInnnnttttCCCCaaaacccchhhheeee (((( iiiinnnntttt _m_a_x_C_o_s_t====111100000000,,,, iiiinnnntttt _s_i_z_e====11117777 ))))
  20.       ~~~~QQQQIIIInnnnttttCCCCaaaacccchhhheeee ()
  21.       QQQQIIIInnnnttttCCCCaaaacccchhhheeee<<<<ttttyyyyppppeeee>>>>&&&& ooooppppeeeerrrraaaattttoooorrrr==== (((( ccccoooonnnnsssstttt QQQQIIIInnnnttttCCCCaaaacccchhhheeee<<<<ttttyyyyppppeeee>>>> &&&& cccc ))))
  22.       iiiinnnntttt mmmmaaaaxxxxCCCCoooosssstttt (((()))) ccccoooonnnnsssstttt
  23.       iiiinnnntttt ttttoooottttaaaallllCCCCoooosssstttt    (((()))) ccccoooonnnnsssstttt
  24.       vvvvooooiiiidddd sssseeeettttMMMMaaaaxxxxCCCCoooosssstttt (((( iiiinnnntttt    mmmm ))))
  25.       vvvviiiirrrrttttuuuuaaaallll uuuuiiiinnnntttt ccccoooouuuunnnntttt (((())))    ccccoooonnnnsssstttt
  26.       uuuuiiiinnnntttt ssssiiiizzzzeeee (((()))) ccccoooonnnnsssstttt
  27.       bbbboooooooollll iiiissssEEEEmmmmppppttttyyyy (((()))) ccccoooonnnnsssstttt
  28.       bbbboooooooollll iiiinnnnsssseeeerrrrtttt ((((    lllloooonnnngggg _k,,,,    ccccoooonnnnsssstttt ttttyyyyppppeeee **** _d,,,,    lllloooonnnngggg _c
  29.       bbbboooooooollll rrrreeeemmmmoooovvvveeee ((((    lllloooonnnngggg kkkk ))))
  30.       ttttyyyyppppeeee****    ttttaaaakkkkeeee (((( lllloooonnnngggg kkkk ))))
  31.       vvvviiiirrrrttttuuuuaaaallll vvvvooooiiiidddd cccclllleeeeaaaarrrr (((())))
  32.       ttttyyyyppppeeee****    ffffiiiinnnndddd (((( lllloooonnnngggg _k,,,, bbbboooooooollll _r_e_f====TTTTRRRRUUUUEEEE )))) ccccoooonnnnsssstttt
  33.       ttttyyyyppppeeee****    ooooppppeeeerrrraaaattttoooorrrr[[[[]]]] (((( lllloooonnnngggg kkkk )))) ccccoooonnnnsssstttt
  34.       vvvvooooiiiidddd ssssttttaaaattttiiiissssttttiiiiccccssss (((()))) ccccoooonnnnsssstttt
  35.  
  36.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  37.       The QIntCache    class is a template class that provides    a
  38.       cache    based on long keys.
  39.  
  40.       QIntCache is implemented as both a template and a macro
  41.       class. Define    a template instance QIntCache<X> to create a
  42.       cache    that operates on pointers to X,    or X*.
  43.  
  44.       A cache is a least recently used (LRU) list of cache items.
  45.       Each cache item has a    cost. The sum of item costs,
  46.       totalCost(), will not    exceed the maximum cache cost,
  47.       maxCost(). If    inserting a new    item would cause the total
  48.       cost to exceed the maximum cost, the least recently used
  49.       items    in the cache are deleted.
  50.  
  51.       Apart    from insert, by    far the    most important function    is
  52.       find() (which    also exists as operatior[]). This function
  53.       looks    up an item, returns it,    and by default marks it    as
  54.       being    the least recently used    item.
  55.  
  56.       There    are also methods to remove() an    object from the    cache
  57.       and delete it, and to    take() an object out of    the cache
  58.       without deleting it.
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                         (printed 9/22/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      QQQQIIIInnnnttttCCCCaaaacccchhhheeee((((3333qqqqtttt))))    TTTTrrrroooollllllll TTTTeeeecccchhhh AAAASSSS ((((9999 JJJJuuuullllyyyy 1111999999998888))))    QQQQIIIInnnnttttCCCCaaaacccchhhheeee((((3333qqqqtttt))))
  71.  
  72.  
  73.  
  74.       QIntCache, as    it must, takes over ownership of the items you
  75.       insert. That implies that it will delete the items at    its
  76.       discretion, and that you must    _n_o_t delete them. There is one
  77.       exception, however: If the cost of an    object you try to
  78.       insert() is higher than the allowed total cost of the    cache,
  79.       insert() returns FALSE and in    this case you must delete the
  80.       object yourself.
  81.  
  82.       In addition to totalCost() and maxCost()/setMaxCost(), there
  83.       are access functions to obtain the number of items in    the
  84.       cache    (count()), the size of the hash    array (size(), set
  85.       using    the constructor) and whether the cache is empty    (you
  86.       guessed it: isEmpty()). Finally, there is a statistics(),
  87.       which    prints various cache statistics    on stdout.
  88.  
  89.       There    is also    a QIntCacheIterator which may be used to
  90.       traverse the items in    the cache in arbritrary    order.
  91.  
  92.       See also: QIntCacheIterator, QCache and Collection Classes
  93.  
  94.      MMMMEEEEMMMMBBBBEEEERRRR FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNN DDDDOOOOCCCCUUUUMMMMEEEENNNNTTTTAAAATTTTIIIIOOOONNNN
  95.      QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::QQQQIIIInnnnttttCCCCaaaacccchhhheeee (((( ccccoooonnnnsssstttt QQQQIIIInnnnttttCCCCaaaacccchhhheeee<<<<ttttyyyyppppeeee>>>> &&&& cccc ))))
  96.       For internal use only.
  97.  
  98.      QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::QQQQIIIInnnnttttCCCCaaaacccchhhheeee (((( iiiinnnntttt    mmmmaaaaxxxxCCCCoooosssstttt====111100000000,,,, iiiinnnntttt ssssiiiizzzzeeee====11117777 ))))
  99.       Constructs an    empty cache with maximum allowed total cost
  100.       _m_a_x_C_o_s_t and optimized    to contain a bit less than _s_i_z_e    items.
  101.  
  102.      QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::~~~~QQQQIIIInnnnttttCCCCaaaacccchhhheeee (((())))
  103.       Destroys the object and all objects in it.
  104.  
  105.      vvvvooooiiiidddd QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::cccclllleeeeaaaarrrr (((()))) [[[[vvvviiiirrrrttttuuuuaaaallll]]]]
  106.       Removes all items from the cache, and    deletes    them.
  107.  
  108.       All cache iterators that operate this    on cache are reset.
  109.  
  110.       See also: remove() and take().
  111.  
  112.       Reimplemented    from QCollection.
  113.  
  114.      uuuuiiiinnnntttt QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::ccccoooouuuunnnntttt (((()))) ccccoooonnnnsssstttt [[[[vvvviiiirrrrttttuuuuaaaallll]]]]
  115.       Returns the number of    items in the cache.
  116.  
  117.       See also: totalCost().
  118.  
  119.       Reimplemented    from QCollection.
  120.  
  121.      ttttyyyyppppeeee **** QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::ffffiiiinnnndddd (((( lllloooonnnngggg kkkk,,,, bbbboooooooollll rrrreeeeffff====TTTTRRRRUUUUEEEE )))) ccccoooonnnnsssstttt
  122.       Returns the item associated with \ k,    or null    if the key
  123.       does not exist in the    cache. If _r_e_f is TRUE (the default),
  124.       the item is moved to the front of the    LRU list.
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                         (printed 9/22/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      QQQQIIIInnnnttttCCCCaaaacccchhhheeee((((3333qqqqtttt))))    TTTTrrrroooollllllll TTTTeeeecccchhhh AAAASSSS ((((9999 JJJJuuuullllyyyy 1111999999998888))))    QQQQIIIInnnnttttCCCCaaaacccchhhheeee((((3333qqqqtttt))))
  137.  
  138.  
  139.  
  140.       If there are two or more items with equal keys, then the one
  141.       that was inserted last is returned.
  142.  
  143.      bbbboooooooollll QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::iiiinnnnsssseeeerrrrtttt (((( lllloooonnnngggg kkkk,,,, ccccoooonnnnsssstttt ttttyyyyppppeeee **** dddd,,,, lllloooonnnngggg cccc====1111,,,,    iiiinnnntttt
  144.       pppp====0000 ))))
  145.       Inserts the item _d into the cache with key _k,    cost (default
  146.       1) and priority _p (default 0). Returns TRUE if it succeeds
  147.       and FALSE if it fails.
  148.  
  149.       The cache's size is limited, and if the total    cost is    too
  150.       high,    QIntCache will delete some of the least-used objects.
  151.  
  152.       WWWWaaaarrrrnnnniiiinnnngggg:::: If this function returns FALSE, you must delete _d
  153.       yourself. Additionally, be very careful about    using _d    after
  154.       calling this function, as any    other insertions into the
  155.       cache, from anywhere in the application, or within Qt
  156.       itself, could    cause the object to be discarded from the
  157.       cache, and the pointer to become invalid.
  158.  
  159.      bbbboooooooollll QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::iiiissssEEEEmmmmppppttttyyyy (((())))    ccccoooonnnnsssstttt
  160.       Returns TRUE if the cache is empty, or TRUE if there is at
  161.       least    one object in it.
  162.  
  163.      iiiinnnntttt QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::mmmmaaaaxxxxCCCCoooosssstttt (((()))) ccccoooonnnnsssstttt
  164.       Returns the maximum allowed total cost of the    cache.
  165.  
  166.       See also: setMaxCost() and totalCost().
  167.  
  168.      QQQQIIIInnnnttttCCCCaaaacccchhhheeee<<<<ttttyyyyppppeeee>>>>&&&& QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::ooooppppeeeerrrraaaattttoooorrrr==== (((( ccccoooonnnnsssstttt QQQQIIIInnnnttttCCCCaaaacccchhhheeee<<<<ttttyyyyppppeeee>>>> &&&& cccc
  169.       ))))
  170.       For internal use only.
  171.  
  172.      ttttyyyyppppeeee **** QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::ooooppppeeeerrrraaaattttoooorrrr[[[[]]]] (((( lllloooonnnngggg kkkk )))) ccccoooonnnnsssstttt
  173.       Returns the item associated with _k, or null if _k does    not
  174.       exist    in the cache, and moves    the item to the    front of the
  175.       LRU list.
  176.  
  177.       If there are two or more items with equal keys, then the one
  178.       that was inserted last is returned.
  179.  
  180.       This is the same as find( k, TRUE ).
  181.  
  182.       See also: find().
  183.  
  184.      bbbboooooooollll QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::rrrreeeemmmmoooovvvveeee (((( lllloooonnnngggg kkkk ))))
  185.       Deletes the item associated with _k, and returns TRUE if the
  186.       item was present in the cache    or FALSE if it was not.
  187.  
  188.       If there are two or more items with equal keys, then the one
  189.       that was inserted last is is deleted.
  190.  
  191.       All iterators    that refer to the removed item are set to
  192.  
  193.  
  194.  
  195.      Page 3                         (printed 9/22/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      QQQQIIIInnnnttttCCCCaaaacccchhhheeee((((3333qqqqtttt))))    TTTTrrrroooollllllll TTTTeeeecccchhhh AAAASSSS ((((9999 JJJJuuuullllyyyy 1111999999998888))))    QQQQIIIInnnnttttCCCCaaaacccchhhheeee((((3333qqqqtttt))))
  203.  
  204.  
  205.  
  206.       point    to the next item in the    cache's    traversal order.
  207.  
  208.       See also: take() and clear().
  209.  
  210.      vvvvooooiiiidddd QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::sssseeeettttMMMMaaaaxxxxCCCCoooosssstttt    (((( iiiinnnntttt mmmm    ))))
  211.       Sets the maximum allowed total cost of the cache to _m. If
  212.       the current total cost is above _m, some items    are deleted
  213.       immediately.
  214.  
  215.       See also: maxCost() and totalCost().
  216.  
  217.      uuuuiiiinnnntttt QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::ssssiiiizzzzeeee (((()))) ccccoooonnnnsssstttt
  218.       Returns the size of the hash array used to implement the
  219.       cache. This should be    a bit bigger than count() is likely to
  220.       be.
  221.  
  222.      ttttyyyyppppeeee **** QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::ttttaaaakkkkeeee (((( lllloooonnnngggg kkkk ))))
  223.       Takes    the item associated with _k out of the cache without
  224.       deleting it, and returns a pointer to    the item taken out, or
  225.       null if the key does not exist in the    cache.
  226.  
  227.       If there are two or more items with equal keys, then the one
  228.       that was inserted last is taken.
  229.  
  230.       All iterators    that refer to the taken    item are set to    point
  231.       to the next item in the cache's traversal order.
  232.  
  233.       See also: remove() and clear().
  234.  
  235.      iiiinnnntttt QQQQIIIInnnnttttCCCCaaaacccchhhheeee::::::::ttttoooottttaaaallllCCCCoooosssstttt (((()))) ccccoooonnnnsssstttt
  236.       Returns the total cost of the    items in the cache. This is an
  237.       integer in the range 0 to maxCost().
  238.  
  239.       See also:  setMaxCost().
  240.  
  241.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  242.       hhhhttttttttpppp::::////////wwwwwwwwwwww....ttttrrrroooollllllll....nnnnoooo////qqqqtttt////qqqqiiiinnnnttttccccaaaacccchhhheeee....hhhhttttmmmmllll
  243.  
  244.      CCCCOOOOPPPPYYYYRRRRIIIIGGGGHHHHTTTT
  245.       Copyright 1992-1997 Troll Tech AS.  See the LICENSE file
  246.       included in the distribution for a complete license
  247.       statement.
  248.  
  249.      AAAAUUUUTTTTHHHHOOOORRRR
  250.       Generated automatically from the source code.
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                         (printed 9/22/98)
  262.  
  263.  
  264.  
  265.